package com.frejoys.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.frejoys.common.dto.admin.OrderSnAndPageDto;
import com.frejoys.common.vo.admin.OrderGoodsListVo;
import com.frejoys.common.vo.app.GoodsNameAndCoverVo;
import com.frejoys.common.vo.order.OrderGoodsVo;
import com.frejoys.dao.entity.OrderGoods;

import java.util.List;
import java.util.Map;

public interface OrderGoodsService extends IService<OrderGoods> {

    default OrderGoods getOnly(QueryWrapper<OrderGoods> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    default OrderGoods getOnly(LambdaQueryWrapper<OrderGoods> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    boolean addInfo(List<OrderGoods> list);

    // 根据订单编号获取商品信息
    List<OrderGoods> getGoodsListByOrderSn(Long orderSn);

    /**
     * 根据订单编号查询订单商品明细信息
     */
    List<OrderGoodsVo> getGoodsListDetailByOrderSn(Long orderSn);

    //管理员查询订单商品列表
    IPage<OrderGoodsListVo> orderGoodsListInfo(OrderSnAndPageDto dto);

    //根据订单号查询商品列表
    Map<Long, List<GoodsNameAndCoverVo>> goodsListByOrderSns(List<Long> orderSns);
}
